// public static final int FONT_10		=	0;
// public static final int FONT_14		=	1;
// public static final int FONT_14_2	=	2;
// public static int life=3;
//public static XSprite sprArrow;
//public static int s_icurrentMenuPos=0;
//int iItem=0;
public static String[] astrMeNuOptionItem = {"MUSIC", "SOUND"};
public static Image m_imgOptionBG;
//Image m_imgMainMenuSprite;
//public static Sprite m_SprConvatchuyendong;
//public static int s_control=5;
// public static int s_AniPositionx;
// public static int s_AniDirection;
// int[] arrSequenceLeft  = {4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,};
// int[] arrSequenceRight = {8,8,8,8,8,8,9,9,9,9,9,9,10,10,10,10,10,11,11,11,11,11,};
// int[] arrSequenceDown =  {0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3};
// int[] arrSequenceUp =	 {12,12,12,12,12,13,13,13,13,13,14,14,14,14,14,15,15,15,15,15,};


// void Select_MainMenu()
// {
	// switch (s_icurrentMenuPos)
	// {
		// case 0: SwitchState(GameState.NextLevel);  break;
		// case 1: SwitchState(GameState.Options);	break;
		// case 2: SwitchState(GameState.Help); break;
		// case 3: SwitchState(GameState.HighScore); break;
		// case 4: SwitchState(GameState.About); break;
		// case 5: SwitchState(GameState.Exit); break;
	// }
// }

void UpdateOptions(int mode)
{
	if (mode == UpdateType.UPDATE)
	{   //s_keyPressed=0;
		//System.out.println("**********MODE UPDATE*************");
		if(IsKeyPressed(DK_SOFT_RIGHT)&&!isIGMenu)
			{
				SwitchState(GameState.MainMenu);
			}
		if(IsKeyPressed(DK_SOFT_RIGHT)&&isIGMenu)
			{
				SwitchState(GameState.InGameMenu);
			}	
		if (IsKeyPressed(GK_DOWN)) {
			//m_SprConvatchuyendong.setFrameSequence(arrSequenceDown);
			if (++s_icurrentMenuPos > 1) s_icurrentMenuPos = 0;
		}
		else if (IsKeyPressed(GK_UP)) {
			//m_SprConvatchuyendong.setFrameSequence(arrSequenceUp);
			
			if (--s_icurrentMenuPos < 0) s_icurrentMenuPos = 1;
		}
		else if ((IsKeyPressed(GK_SELECT)||IsKeyPressed(DK_SOFT_LEFT))&&s_icurrentMenuPos==0)
		{
		hasSound=!hasSound;
		PlaySound("/bgMusic.mid",2);
		StopSound("/bgMusic.mid",2);
		
		}
		else if ((IsKeyPressed(GK_SELECT)||IsKeyPressed(DK_SOFT_LEFT))&&s_icurrentMenuPos==1)
		{
		hasSfx=!hasSfx;
		}
			//Select_MainMenu();
 		// else if (IsKeyPressed(GK_LEFT)) {
			// s_AniDirection = 4;
			//m_SprConvatchuyendong.setFrameSequence(arrSequenceLeft);
			//m_SprConvatchuyendong.move(-4, 0);
			//s_AniPositionx+=5;
		// }
		// else if (IsKeyPressed(GK_RIGHT))
		// {
			// s_AniDirection = 2;
			//m_SprConvatchuyendong.setFrameSequence(arrSequenceRight);
			//m_SprConvatchuyendong.move(+4, 0);
			//s_AniPositionx-=5;
		// }	
    } //end of Update mode
	
	if (mode == UpdateType.PAINT)
	{   //s_keyPressed=0;
		if (m_imgOptionBG != null)
		{
			s_g.drawImage(m_imgOptionBG, 0, 0, Graphics.TOP|Graphics.LEFT);
		}
		fonts[1].drawString("OPTIONS",SCREEN_W>>1,40,Graphics.HCENTER,s_g);
		// draw menu item bg
		//for (iItem = 0; iItem < 2; iItem++) {
			// if (iItem == s_icurrentMenuPos) s_g.setColor(0x2582A7); 
			// else s_g.setColor(c_white);
			// s_g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE));
			
			// drawString(s_g, astrMenuItem[iItem], 0, SCREEN_W/2, 65 + 33 * iItem, 1);
			if(0==s_icurrentMenuPos)
			{
			fonts[1].drawString(astrMeNuOptionItem[0]+(hasSound?": ON":": OF"),SCREEN_W>>1,100 + 43 * 0,Graphics.HCENTER,s_g);
			fonts[2].drawString(astrMeNuOptionItem[1]+(hasSfx?": ON":": OF"),SCREEN_W>>1,100 + 43 * 1,Graphics.HCENTER,s_g);
			}
			else
			{
			fonts[2].drawString(astrMeNuOptionItem[0]+(hasSound?": ON":": OF"),SCREEN_W>>1,100 + 43 * 0,Graphics.HCENTER,s_g);
			fonts[1].drawString(astrMeNuOptionItem[1]+(hasSfx?": ON":": OF"),SCREEN_W>>1,100 + 43 * 1,Graphics.HCENTER,s_g);
			}
			
		//}
		// Draw the identified animated icon
		// if (m_imgMainMenuSprite != null)
		// {				
			// try{						
				// m_SprConvatchuyendong.setPosition(SCREEN_W - s_AniPositionx, 30+33*s_icurrentMenuPos);
			// }catch(Exception e)
			// {
				// System.out.println("Co ngoai le****%(*%&%*(%&*%");
			// }
			
		// }
		
		// if(m_SprConvatchuyendong!=null)
		// {
			// m_SprConvatchuyendong.paint(s_g);		
			// m_SprConvatchuyendong.nextFrame();
		// } 
		int titleW=0;
		for (int i = 0; i < 3; i++)
		{
		    titleW = fonts[1].stringWidth(astrMeNuOptionItem[s_icurrentMenuPos]+(hasSound?": ON":": OF"));
			sprArrow.paintAnim(s_g, 0, s_frameCount, (SCREEN_W>>1)
					+ (titleW >> 1) + 3, 102+43*s_icurrentMenuPos);
			sprArrow.paintAnim(s_g, 1, s_frameCount, (SCREEN_W>>1)
					- (titleW >> 1) - 17, 102+43*s_icurrentMenuPos);
		}
		
	}
	
	if (mode == UpdateType.CTOR)
	{   s_keyPressed=0;
	    s_icurrentMenuPos=0;
		//life=3;
		try
		{  sprArrow = new XSprite("/arrow.png", 12, 16, new byte[][] {
				{ 0, 1, 2, 1 }, { 3, 4, 5, 4 } });
			m_imgOptionBG = Image.createImage("/bg_pink_02.png");			
			//m_imgMainMenuSprite	= Image.createImage("/monter_strip16.png");		
			
			//m_SprConvatchuyendong = new Sprite(m_imgMainMenuSprite, 60, 57);
			//m_SprConvatchuyendong.setFrameSequence(arrSequenceLeft);
			
			// initFontSystem();
			//s_AniPositionx = 40;	
			
		} 
		catch (Exception e)
		{
			System.out.println("e:::::::::Khong tim thay hinh:::::::: " + e.getMessage());
		}
	}
	if (mode == UpdateType.DTOR)
	{
	 s_keyPressed=0;
	 sprArrow=null;
	 m_imgOptionBG=null;
	 
	}
}
// NOT YET RESOLVED: TWO EXCEPTION WHEN LOAD FONT AND DRAW STRING, SEE IN CFont.h for more detail
